# coding: utf-8

import datetime

from app.op.constant import DemandCate, DemandColor, DemandMalf


def redis_user_openid_key(openid):
    """
    生成绑定手机的营销客户缓存key(为一天一次)
    """
    date_key = str(datetime.date.today())
    return openid + '_' + date_key


def not_binded_redis_user_openid_key(openid):
    """
    created by chenhj at 2017/10/17
    生成未绑定手机的营销客户缓存key(为一周一次, 不从key上体现, 直线通过ttl去实现)
    """
    return 'not_binded_openid_{openid}'.format(openid=openid)


def get_demand_price(demand):
    """
    create by ld_wu 2018-02-26
    项目一口价价格
    :param demand:
    :return:
    """
    offer = 15
    if demand.cate == DemandCate.MAINTAIN.value:
        if demand.color == DemandColor.FULL_COLOR.value:
            if demand.malf in [DemandMalf.BRIGHT_PROBLEM.value,
                               DemandMalf.COLOR_PROBLEM.value]:
                # 维修、全彩、（整屏或部分不亮\有色彩问题)
                offer = 30
            else:
                # 维修、全彩、（出现亮点、暗点\无法更换屏幕内容\屏幕移位\其他)
                offer = 25
    return offer


